package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IDispatchEngineeringOrderListView;
import com.cloudsigns.factorymanager2.engineering.IView.IEngineeringInstallOrderDetailView;
import com.cloudsigns.factorymanager2.engineering.bean.EngineeringInstallationOrderBean;
import com.cloudsigns.factorymanager2.engineering.bean.OrderParentBean;
import com.cloudsigns.factorymanager2.engineering.model.DispatchEngineeringOrderListModel;
import com.cloudsigns.factorymanager2.engineering.model.EngineeringInstallOrderDetailModel;
import com.cloudsigns.factorymanager2.engineering.model.IDispatchEngineeringOrderListModel;
import com.cloudsigns.factorymanager2.engineering.model.IEngineeringInstallOrderDetailModel;

import java.util.List;

/**
 * Created by tony on 2018/4/2.
 */

public class EngineeringInstallOrderDetailPresenter {
    private IEngineeringInstallOrderDetailView view;
    private IEngineeringInstallOrderDetailModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public EngineeringInstallOrderDetailPresenter(IEngineeringInstallOrderDetailView view) {
        this.view = view;
        this.model = new EngineeringInstallOrderDetailModel();
    }

    public void getEngineeringInstallOrderDetail() {


        model.getEngineeringInstallOrderDetail(view.getOrderId(),view.getItemId(),view.getFeedbackDate(), new EngineeringInstallOrderDetailModel.OnEngineeringInstallOrderDetailListener() {
            @Override
            public void successed(final EngineeringInstallationOrderBean engineeringInstallationOrderBean) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getEngineeringInstallOrderDetailSuccessed(engineeringInstallationOrderBean);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getEngineeringInstallOrderDetailFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
